<!-- 
     How to turn a TabControl into an Outlook Bar
     Demo By Richard Matheson, July 2008 
     http://www.codeproject.com/KB/WPF/XAML_OutlookBar.aspx
     This code is licensed under the Code Project Open License (http://www.codeproject.com/info/cpol10.aspx)
-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:CompositeWPFContrib.Composite.Wpf.Controls">
    <Style TargetType="{x:Type Controls:OutlookBarControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:OutlookBarControl}">
                    <ControlTemplate.Resources>
                        <!-- To change the colour scheme of the Outlook Bar, change the colors of these brushes -->
                        <SolidColorBrush x:Key="LabelHighlightBrush" Color= "#FFFFFF" />
                        <SolidColorBrush x:Key="CaptionBrush" Color= "#15428B" />
                        <SolidColorBrush x:Key="BorderBrush" Color="#6593CF" />
                        <LinearGradientBrush x:Key="LabelBrush" StartPoint="0, 0" EndPoint="0,1">
                            <GradientStop Color="#E3EFFF" Offset="0" />
                            <GradientStop Color="#AFD2FF" Offset="1" />
                        </LinearGradientBrush>
                        <LinearGradientBrush x:Key="ButtonNormalBrush" StartPoint="0, 0" EndPoint="0,1">
                            <GradientStop Color="#E3EFFF" Offset="0" />
                            <GradientStop Color="#C4DDFF" Offset="0.40625" />
                            <GradientStop Color="#ADD1FF" Offset="0.40625" />
                            <GradientStop Color="#C0DBFF" Offset="1" />
                        </LinearGradientBrush>
                        <LinearGradientBrush x:Key="ButtonSelectedBrush" StartPoint="0, 0" EndPoint="0,1">
                            <GradientStop Color="#FFD9AA" Offset="0" />
                            <GradientStop Color="#FFBB6E" Offset="0.40625" />
                            <GradientStop Color="#FFAB3F" Offset="0.40625" />
                            <GradientStop Color="#FEE17A" Offset="1" />
                        </LinearGradientBrush>
                        <LinearGradientBrush x:Key="ButtonPressedBrush" StartPoint="0, 0" EndPoint="0,1">
                            <GradientStop Color="#FFBD69" Offset="0" />
                            <GradientStop Color="#FFAC42" Offset="0.40625" />
                            <GradientStop Color="#FB8C3C" Offset="0.40625" />
                            <GradientStop Color="#FED364" Offset="1" />
                        </LinearGradientBrush>
                        <LinearGradientBrush x:Key="ButtonHoverBrush" StartPoint="0, 0" EndPoint="0,1">
                            <GradientStop Color="#FFFEE4" Offset="0" />
                            <GradientStop Color="#FFE8A7" Offset="0.40625" />
                            <GradientStop Color="#FFD767" Offset="0.40625" />
                            <GradientStop Color="#FFE69E" Offset="1" />
                        </LinearGradientBrush>
                        <LinearGradientBrush x:Key="MyHGridSplitterBlueGradientBrush" EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="#FFFDFDFD" Offset="0"/>
                            <GradientStop Color="#FFC0DEFF" Offset="0.654"/>
                            <GradientStop Color="#FFC0D9FB" Offset="1"/>
                        </LinearGradientBrush>
                        <!-- This style sets the default template for a TabItem -->
                        <Style TargetType="{x:Type TabItem}">
                            <Setter Property="Header" Value="{Binding Path=Content.(Controls:OutlookBarControl.OutlookBarMetadata).Title, RelativeSource={RelativeSource Self}}" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type TabItem}">
                                        <!-- These triggers control the background and text colour of the Outlook bar buttons when the are selected and/or hovered over -->
                                        <ControlTemplate.Triggers>
                                            <MultiTrigger>
                                                <MultiTrigger.Conditions>
                                                    <Condition Property="IsSelected" Value="False" />
                                                    <Condition Property="IsMouseOver" Value="False" />
                                                </MultiTrigger.Conditions>
                                                <MultiTrigger.Setters>
                                                    <Setter Property="Background" Value="{StaticResource ButtonNormalBrush}" />
                                                </MultiTrigger.Setters>
                                            </MultiTrigger>
                                            <MultiTrigger>
                                                <MultiTrigger.Conditions>
                                                    <Condition Property="IsSelected" Value="False" />
                                                    <Condition Property="IsMouseOver" Value="True" />
                                                </MultiTrigger.Conditions>
                                                <MultiTrigger.Setters>
                                                    <Setter Property="Background" Value="{StaticResource ButtonHoverBrush}" />
                                                </MultiTrigger.Setters>
                                            </MultiTrigger>
                                            <Trigger Property="IsSelected" Value="True">
                                                <Setter Property="TextElement.Foreground" Value="Black" />
                                                <Setter Property="Background" Value="{StaticResource ButtonSelectedBrush}" />
                                            </Trigger>
                                            <Trigger Property="IsSelected" Value="False">
                                                <Setter Property="TextElement.Foreground" Value="{StaticResource CaptionBrush}" />
                                            </Trigger>
                                            <MultiTrigger>
                                                <MultiTrigger.Conditions>
                                                    <Condition Property="IsSelected" Value="True" />
                                                    <Condition Property="IsMouseOver" Value="True" />
                                                </MultiTrigger.Conditions>
                                                <MultiTrigger.Setters>
                                                    <Setter Property="Background" Value="{StaticResource ButtonPressedBrush}" />
                                                </MultiTrigger.Setters>
                                            </MultiTrigger>
                                        </ControlTemplate.Triggers>
                                        <!-- This defines the look of the individual TabItems -->
                                        <Grid Background="{TemplateBinding Background}" MinHeight="32" SnapsToDevicePixels="True">
                                            <Line Stroke="{StaticResource BorderBrush}" VerticalAlignment="Top" Stretch="Fill" X2="1" SnapsToDevicePixels="True" />
                                            <ContentPresenter Margin="5,0,5,0" TextBlock.FontFamily="Tahoma" TextBlock.FontSize="8pt" TextBlock.FontWeight="Bold" TextBlock.Foreground="{StaticResource CaptionBrush}" Content="{TemplateBinding Header}" VerticalAlignment="Center"/>
                                        </Grid>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ControlTemplate.Resources>
                    <!-- This is the template for the TabControl itself -->
                    <Border BorderBrush="{StaticResource BorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" >
                        <DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" LastChildFill="True">

                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="32"/>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="{Binding Path=Height, ElementName=StackPanel, Mode=Default}" MaxHeight="{Binding Path=ActualHeight, ElementName=StackPanel, Mode=Default}" MinHeight="32"/>
                                </Grid.RowDefinitions>
                                <GridSplitter HorizontalAlignment="Stretch" Grid.Row="1" Height="7" VerticalAlignment="Bottom" DragIncrement="32" Opacity="1" Panel.ZIndex="1"  Background="{DynamicResource MyHGridSplitterBlueGradientBrush}"/>
                                <!-- This is the host panel that contains the tab items -->
                                <StackPanel Grid.Row="2" x:Name="StackPanel" VerticalAlignment="Top" Height="Auto" DockPanel.Dock="Bottom" IsItemsHost="True" />
                                <!-- This is the label that appears at the top of the TabControl -->
                                <Grid Grid.Row="0" DockPanel.Dock="Top" MinHeight="28" Background="{StaticResource ButtonNormalBrush}"  SnapsToDevicePixels="True">
                                    <TextBlock FontFamily="Tahoma" Foreground="{StaticResource CaptionBrush}" VerticalAlignment="Center" Margin="5,0" FontSize="16" FontWeight="Bold" Text="{Binding Path=SelectedItem.(Controls:OutlookBarControl.OutlookBarMetadata).Title, RelativeSource={RelativeSource AncestorType={x:Type Controls:OutlookBarControl}}}" ></TextBlock>
                                    <Line Stroke="{StaticResource BorderBrush}" VerticalAlignment="Bottom" X2="1" Stretch="Fill"/>
                                </Grid>
                                <!-- This is the selected content pane that appears in the Outlook Bar -->
                                <ContentPresenter Grid.Row="1" Content="{TemplateBinding SelectedContent}" />
                            </Grid>
                        </DockPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>